<?php require("check_login.php"); ?>
<?php require("user_settings.php"); ?>
<?php
	$uid=$_SESSION['id'];
	$user = getUser($uid);
	#$user_file = "users/".$uid."/settings.json";
	#$users = json_decode(file_get_contents($user_file),true);
	if(!isset($user['cname'])) {
		$user['cname'] = $uid;
		$COMPID = compCntIncrease();#file_get_contents("compCnt");
		#echo "COMPID $COMPID";
		#$COMPID=(int)$COMPID + 1;
		#echo "COMPID $COMPID";
		#file_put_contents("compCnt",$COMPID);
		$user['cid'] = $COMPID;
	}
	if(!isset($user['rpass'])) {
		$user['rpass'] = rand(100000,999999);
	}
	if(!isset($user['email'])) {
		$user['email'] = "unspecific@localhost";
	}
	if(!isset($user['age'])) {
		$user['age'] = "unspecified";
	}
	if(!isset($user['job'])) {
		$user['job'] = "unspecified";
	}
	if(!isset($user['expertise'])) {
		$user['expertise'] = "Linux driver programming";
	}
	if(!isset($user['brief'])) {
		$user['brief'] = "unsepcified";
	}
	if(!isset($user['identity'])) {
		$user['identity'] = "student";
	}


	#file_put_contents("$user_file",json_encode($user));
	setUser($uid, $user);
	#$file = "user_company_mapping.json";
	#$mappings = json_decode(file_get_contents($file),true);
	#$mappings[$COMPID] = $uid;
	#file_put_contents("$file",json_encode($mappings));
	setCompUserMapping($COMPID, $uid);
	echo "<script lang=javascript> document.location.href=(\"topframe.php\");</script>";

?>
